from starlette.responses import Response, PlainTextResponse, HTMLResponse
from fastapi import APIRouter
from pathlib import Path
import yaml
from lly.vim import command
from lly.logconfig import logger
from lly import markdown
from starlette.templating import Jinja2Templates
from starlette.requests import Request
from lly.server import root_path

router = APIRouter()


@router.get('/dao/data.json')
def dao(id: int = 0):
    '''
    返回道德经的数据
    '''
    content = "empty"
    #  print(content)
    dao_path = Path(f"{root_path}/static/dao.yaml")
    content = dao_path.read_text()
    content = yaml.safe_load(content)
    return content


@router.get('/zhouyi/data.json')
def zhouyi(id: int = 0):
    '''
    返回周易的数据
    '''
    content = "empty"
    #  print(content)
    dao_path = Path(f"{root_path}/static/zhouyi.yaml")
    content = dao_path.read_text()
    content = yaml.safe_load(content)
    return content
